<template>
  <el-row class="tac">
    <el-col :span="12">
      <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        @open="handleOpen"
        @close="handleClose"
        background-color="#1B42FF"
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <h4>五菱扳手</h4>
        <!-- <el-menu-item
          v-for="item in menuData"
          :key="item.name"
          :index="item.name">
          <i :class="`el-icon-${item.icon}`"></i>
          <span slot="title">{{ item.label }}</span>
        </el-menu-item> -->

        <el-submenu
          v-for="item in menuData"
          :key="item.name"
          :index="item.name"
          text-color="#fff"
        >
          <template slot="title">
            <i :class="`el-icon-${item.icon}`"></i>
            <span slot="title" @click="clickMenu(item)">{{ item.label }}</span>
          </template>
          <el-menu-item-group
            v-for="subItem in item.children"
            :key="subItem.path"
            text-color="#fff"
          >
            <el-menu-item @click="clickMenu(subItem)" :index="subItem.path">{{
              subItem.label
            }}</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-menu>
    </el-col>
  </el-row>
</template>

<script>
export default {
  data() {
    return {
      menuData: [
        {
          path: "/dataBoard",
          name: "dataBoard",
          label: "数据看板",
          icon: "s-marketing",
          url: "DataBoard.vue",
          // children: [
          //   {
          //     path: "/",
          //     name: "",
          //     label: "页面1",
          //   },
          // ],
        },
        // 制造执行
        {
          path: "/ManufacturingExecution",
          name: "ManufacturingExecution",
          label: "制造执行MES",
          icon: "s-home",
          url: "ManufacturingExecution.vue",
          children: [
            {
              path: "/CarModels",
              name: "CarModels",
              label: "汽车模型",
              url: "CarModels.vue",
            },
            {
              path: "/Client",
              name: "Client",
              label: "客户端",
              url: "Client.vue",
            },
            {
              path: "/StationManagemen",
              name: "StationManagemen",
              label: "工位管理",
              url: "StationManagemen.vue",
            },
          ],
        },
        {
          path: "/dropDown",
          name: "dropDown",
          label: "下级菜单",
          icon: "s-home",
          url: "DropDown.vue",
          // children: [
          //   {
          //     path: "/",
          //     name: "",
          //     label: "页面1",
          //   },
          // ],
        },
        {
          path: "/TaskPlan",
          name: "taskPlan",
          label: "任务计划",
          icon: "s-home",
          url: "TaskPlan.vue",
          // children: [
          //   {
          //     path: "/",
          //     name: "",
          //     label: "页面1",
          //   },
          // ],
        },
        {
          path: "/User",
          name: "user",
          label: "用户管理",
          icon: "s-home",
          url: "User.vue",
          children: [
            {
              path: "/AccountManagement",
              name: "AccountManagement",
              label: "账户管理",
              url: "AccountManagement.vue",

            },
            {
              path: "/DepartmentManagement",
              name: "DepartmentManagement",
              label: "部门管理",
              url: "DepartmentManagement.vue",

            },
          ],
        },
      ],
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    // 点击导航菜单
    clickMenu(item) {
      console.log(item);
      // 当页面的路由与跳转的路由不一致的时候才允许跳转
      if (this.$route.path !== item.path) {
        this.$router.push(item.path);
      }
    },
  },
};
</script>
<style lang="less" scoped>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu {
  height: 100vh;
  h4 {
    color: #fff;
    text-align: center;
    line-height: 48px;
    font-size: 16px;
    font-weight: 400;
  }
}
</style>
